package com.example.VolunteerBank.mapper;

import com.example.VolunteerBank.pojo.Article;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ArticleMapper {

    //新增文章
    @Insert("insert into article(title, content, cover_img, state, category_id, create_user, create_time, update_time) VALUES (#{title}, #{content}, #{coverImg}, #{state}, #{categoryId}, #{createUser}, #{createTime}, #{updateTime})")
    void add(Article article);

    //更新文章
    void update(Article article);

    //获取文章详情
    @Select("select * from article where id = #{id}")
    Article queryById(Integer id);

    //删除文章
    @Delete("delete from article where id = #{id}")
    void delete(Integer id);

    //分页查询文章列表
    Page<Article> page(Integer createUser, String categoryId, String state);
}
